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

:root {
    --primary-color: #4A90E2;
    --secondary-color: #5C6AC4;
    --success-color: #47C479;
    --danger-color: #E85D75;
    --warning-color: #FFA500;
    --bg-color: #F7F8FA;
    --surface-color: #FFFFFF;
    --text-primary: #2C3E50;
    --text-secondary: #6C757D;
    --border-color: #DFE3E8;
    --hover-bg: #F0F3F7;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-sm: 4px;
    --transition: all 0.3s ease;
}

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

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

header {
    text-align: center;
    padding: 40px 0 30px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: var(--radius);
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo {
    width: 48px;
    height: 48px;
}

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

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
    padding: 20px;
    background: var(--surface-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn svg {
    width: 18px;
    height: 18px;
}

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

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

.btn-secondary {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

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

.btn-icon {
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

.lang-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.lang-select:hover {
    border-color: var(--primary-color);
}

.lang-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.editor-panel {
    background: var(--surface-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.panel-header {
    padding: 15px 20px;
    background: linear-gradient(to right, #F8F9FA, #FFFFFF);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.panel-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.char-count {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 8px;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
}

.editor-wrapper {
    position: relative;
    height: 500px;
    display: flex;
}

.line-numbers {
    width: 50px;
    padding: 15px 10px;
    background: #F8F9FA;
    border-right: 1px solid var(--border-color);
    text-align: right;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    overflow-y: hidden;
    user-select: none;
}

.code-editor {
    flex: 1;
    padding: 15px;
    border: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    background: var(--surface-color);
    color: var(--text-primary);
    overflow-y: auto;
}

.code-editor:focus {
    outline: none;
    background: #FAFBFC;
}

.error-message {
    display: none;
    padding: 12px 20px;
    background: #FEE;
    color: var(--danger-color);
    border-left: 4px solid var(--danger-color);
    margin: 0 20px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: relative;
    background: var(--surface-color);
    margin: 50px auto;
    padding: 0;
    width: 90%;
    max-width: 600px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-large {
    max-width: 1200px;
}

.modal-header {
    padding: 20px;
    background: linear-gradient(to right, #F8F9FA, #FFFFFF);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.close-btn {
    font-size: 28px;
    font-weight: 300;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.close-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.xpath-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 15px;
    transition: var(--transition);
}

.xpath-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.xpath-results {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.xpath-result {
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.result-header {
    padding: 10px;
    background: var(--bg-color);
    font-weight: 500;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.xpath-result pre {
    padding: 15px;
    margin: 0;
    background: #F8F9FA;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.no-results {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
}

.compare-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.compare-panel {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.compare-panel h4 {
    padding: 10px 15px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.compare-editor {
    width: 100%;
    height: 300px;
    padding: 15px;
    border: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: none;
}

.compare-results {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.success {
    color: var(--success-color);
    padding: 15px;
    background: #E8F5E9;
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 500;
}

.warning {
    color: var(--warning-color);
    padding: 15px;
    background: #FFF3E0;
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 500;
    margin-bottom: 15px;
}

.error {
    color: var(--danger-color);
    padding: 15px;
    background: #FFEBEE;
    border-radius: var(--radius-sm);
    text-align: center;
}

.diff-container {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.diff-item {
    border-bottom: 1px solid var(--border-color);
}

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

.diff-line {
    padding: 8px 15px;
    background: var(--bg-color);
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
}

.diff-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.diff-left,
.diff-right {
    padding: 10px 15px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

.diff-left {
    background: #FFEBEE;
    border-right: 1px solid var(--border-color);
}

.diff-right {
    background: #E8F5E9;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .logo {
        width: 36px;
        height: 36px;
    }
    
    .subtitle {
        font-size: 0.95rem;
    }
    
    .toolbar {
        padding: 15px;
        gap: 10px;
    }
    
    .toolbar-group {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .btn {
        flex: 1;
        min-width: 100px;
        justify-content: center;
    }
    
    .editor-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .editor-wrapper {
        height: 350px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px auto;
    }
    
    .compare-container {
        grid-template-columns: 1fr;
    }
    
    .diff-content {
        grid-template-columns: 1fr;
    }
    
    .diff-left {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1A1D23;
        --surface-color: #2D3139;
        --text-primary: #E4E6EB;
        --text-secondary: #B0B3B8;
        --border-color: #3E4249;
        --hover-bg: #3A3D44;
    }
    
    .code-editor {
        background: #2D3139;
        color: #E4E6EB;
    }
    
    .code-editor:focus {
        background: #323741;
    }
    
    .line-numbers {
        background: #252830;
    }
    
    .xpath-result pre {
        background: #252830;
        color: #E4E6EB;
    }
    
    .modal-content {
        background: #2D3139;
    }
    
    .modal-header {
        background: linear-gradient(to right, #252830, #2D3139);
    }
    
    .xpath-input,
    .compare-editor {
        background: #252830;
        color: #E4E6EB;
        border-color: #3E4249;
    }
    
    .lang-select {
        background: #2D3139;
        color: #E4E6EB;
    }
}