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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    color: #2d3748;
    line-height: 1.6;
}

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

header {
    text-align: left;
    margin-bottom: 40px;
    color: #1a202c;
}

header h1 {
    font-size: 2.75em;
    font-weight: 700;
    margin-bottom: 12px;
    color: #111827;
    letter-spacing: -0.025em;
}

header p {
    font-size: 1.15em;
    color: #6b7280;
    font-weight: 400;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
    min-height: 800px;
}

.input-section,
.output-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-panel,
.output-panel {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.06), 0 4px 40px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 600px;
}

.panel-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 24px 28px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 1.4em;
    color: #1a202c;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.input-controls,
.output-controls {
    display: flex;
    gap: 10px;
}

button {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

button:hover {
    background: #2563eb;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

button:active {
    background: #1d4ed8;
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.file-upload {
    padding: 24px 28px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.file-label {
    display: block;
    background: white;
    border: 2px dashed #cbd5e0;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #4a5568;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.file-label:hover {
    background: #f7fafc;
    border-color: #a0aec0;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    color: #2d3748;
}

#fileInput {
    display: none;
}

#inputText {
    flex: 1;
    border: none;
    padding: 24px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 14px;
    line-height: 1.7;
    resize: none;
    outline: none;
    background: #fafbfc;
    color: #374151;
    border-radius: 0 0 16px 16px;
}

#inputText:focus {
    background: white;
    box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.1);
}

#inputText::placeholder {
    color: #a0aec0;
    font-style: italic;
}

.output-preview {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: white;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
}

.placeholder {
    color: #6c757d;
    text-align: center;
    font-style: italic;
    margin-top: 50px;
}

/* Formatted output styles */
.output-preview h1,
.output-preview h2,
.output-preview h3,
.output-preview h4,
.output-preview h5,
.output-preview h6 {
    color: #1a202c;
    margin: 24px 0 12px 0;
    font-weight: 700;
    line-height: 1.2;
}

.output-preview h1 { 
    font-size: 2.25em; 
    border-bottom: 3px solid #e2e8f0; 
    padding-bottom: 12px;
    margin-bottom: 20px;
}
.output-preview h2 { 
    font-size: 1.875em; 
    border-bottom: 2px solid #e2e8f0; 
    padding-bottom: 10px;
    margin-bottom: 16px;
}
.output-preview h3 { 
    font-size: 1.5em; 
    color: #2d3748;
    margin-bottom: 12px;
}
.output-preview h4 { font-size: 1.25em; color: #2d3748; }
.output-preview h5 { font-size: 1.125em; color: #4a5568; }
.output-preview h6 { font-size: 1em; color: #4a5568; }

.output-preview p {
    margin: 16px 0;
    line-height: 1.7;
    color: #4a5568;
}

.output-preview strong {
    color: #1a202c;
    font-weight: 700;
}

.output-preview em {
    color: #2d3748;
    font-style: italic;
}

.output-preview ul,
.output-preview ol {
    margin: 15px 0;
    padding-left: 30px;
}

.output-preview li {
    margin: 5px 0;
}

.output-preview code {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    color: #e83e8c;
}

.output-preview pre {
    background: #2d3748;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 8px;
    margin: 15px 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.output-preview pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.output-preview blockquote {
    border-left: 4px solid #667eea;
    padding: 10px 20px;
    margin: 15px 0;
    background: #f8f9ff;
    color: #495057;
    font-style: italic;
}

.output-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    border: 1px solid #dee2e6;
}

.output-preview th,
.output-preview td {
    border: 1px solid #dee2e6;
    padding: 12px;
    text-align: left;
}

.output-preview th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

/* Custom formatting styles */
mark,
.highlight {
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 3px;
}

.color-text {
    font-weight: 500;
}

/* Task lists */
.output-preview .task-item {
    margin: 8px 0;
    display: flex;
    align-items: center;
}

.output-preview .task-item input[type="checkbox"] {
    margin-right: 8px;
    margin-top: 0;
}

.output-preview .task-list-item {
    list-style: none;
    margin-left: -20px;
}

.output-preview .task-list-item input[type="checkbox"] {
    margin-right: 8px;
    margin-top: 2px;
}

/* Responsive design */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .input-panel,
    .output-panel {
        height: 50vh;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .panel-header {
        padding: 15px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .input-controls,
    .output-controls {
        flex-wrap: wrap;
    }
}

/* WYSIWYG Formatting Toolbar */
.formatting-toolbar {
    background: #fafbfc;
    border-bottom: 1px solid #e1e5e9;
    padding: 16px 24px;
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    min-height: 60px;
}

.toolbar-group {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.toolbar-btn {
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}

.toolbar-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.toolbar-btn:active,
.toolbar-btn.active {
    background: #e5e7eb;
    color: #111827;
}

.toolbar-select {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
    height: 36px;
    color: #6b7280;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.toolbar-select:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

.toolbar-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Make output area editable */
.output-preview.editable {
    outline: none;
    cursor: text;
    padding: 24px;
    min-height: 200px;
    background: #fafbfc;
    border-radius: 0 0 16px 16px;
}

.output-preview.editable:focus {
    background: white;
    box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.output-preview.editable .placeholder {
    color: #a0aec0;
    pointer-events: none;
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    font-size: 1.1em;
}

/* Hide placeholder when content exists */
.output-preview.editable:not(:empty) .placeholder {
    display: none;
}

/* Ensure proper focus behavior */
.output-preview.editable:focus .placeholder {
    display: none;
}

/* Loading animation */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #667eea;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Instruction boxes */
.instruction-box {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.instruction-box h3 {
    font-size: 1.1em;
    font-weight: 600;
    color: #111827;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.instruction-box h3 i {
    color: #3b82f6;
    font-size: 1em;
}

.instruction-box ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.instruction-box li {
    margin-bottom: 12px;
    padding-left: 0;
    color: #4b5563;
    line-height: 1.5;
}

.instruction-box li:last-child {
    margin-bottom: 0;
}

.instruction-box strong {
    color: #111827;
    font-weight: 600;
}