 :root {
            --primary-color: #4f46e5;
            --primary-hover: #4338ca;
            --bg-color: #f3f4f6;
            --card-bg: #ffffff;
            --text-main: #1f2937;
            --text-muted: #6b7280;
            --success-bg: #ecfdf5;
            --success-text: #065f46;
            --error-bg: #fef2f2;
            --error-text: #991b1b;
            --border-color: #d1d5db;
        }
        * { box-sizing: border-box; margin: 0; padding: 0; }
        body {
            font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
            background-color: var(--bg-color);
            color: var(--text-main);
            line-height: 1.6;
            display: flex;
            justify-content: center;
            padding: 2rem 1rem;
        }
        .container { width: 100%; max-width: 750px; display: flex; flex-direction: column; gap: 1.5rem; }
        .card {
            background-color: var(--card-bg);
            border-radius: 12px;
            padding: 1.5rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
            transition: all 0.3s ease;
        }
        .header { text-align: center; margin-bottom: 1.5rem; }
        .header h2 { font-size: 1.5rem; color: var(--text-main); }
        .settings-header {
            display: flex; justify-content: space-between; align-items: center;
            cursor: pointer; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color);
        }
        .settings-header h3 { font-size: 1.1rem; color: var(--text-muted); }
        .settings-content { display: none; margin-top: 1rem; flex-direction: column; gap: 1rem; }
        .settings-content.active { display: flex; }
        .form-group { display: flex; flex-direction: column; gap: 0.5rem; }
        label { font-weight: 600; font-size: 0.9rem; }
        
        input[type="text"], input[type="password"], textarea, select {
            width: 100%; padding: 0.75rem; border: 1px solid var(--border-color);
            border-radius: 8px; font-family: inherit; font-size: 0.95rem;
            transition: border-color 0.2s, box-shadow 0.2s;
        }
        input:focus, textarea:focus, select:focus {
            outline: none; border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
        }
        textarea { min-height: 100px; resize: vertical; }
        
        button {
            padding: 0.75rem 1.5rem; border: none; border-radius: 8px;
            font-weight: 600; font-size: 1rem; cursor: pointer;
            transition: background-color 0.2s, transform 0.1s;
            font-family: inherit;
        }
        button:active { transform: scale(0.98); }
        .btn-primary { background-color: var(--primary-color); color: white; width: 100%; margin-top: 1rem; }
        .btn-primary:hover { background-color: var(--primary-hover); }
        .btn-primary:disabled { background-color: #9ca3af; cursor: not-allowed; transform: none; }
        
        .btn-secondary { background-color: #e5e7eb; color: var(--text-main); width: 100%; }
        .btn-secondary:hover { background-color: #d1d5db; }
        .btn-secondary:disabled { background-color: #f3f4f6; color: #9ca3af; cursor: not-allowed;}

        .btn-improve { background-color: #10b981; color: white; margin-top: 0.5rem; width: auto; align-self: flex-start; font-size: 0.85rem; padding: 0.5rem 1rem;}
        .btn-improve:hover { background-color: #059669; }

        .hint { font-size: 0.8rem; color: #d97706; background: #fef3c7; padding: 0.5rem; border-radius: 6px; border: 1px solid #fde68a;}
        
        .status-box {
            display: none; padding: 1.5rem; border-radius: 8px; margin-top: 1.5rem;
            animation: fadeIn 0.4s ease;
        }
        .success { background-color: var(--success-bg); border: 1px solid #a7f3d0; color: var(--text-main); }
        .error { background-color: var(--error-bg); border: 1px solid #fecaca; color: var(--error-text); }
        .error pre {
            background-color: rgba(255, 255, 255, 0.5); padding: 0.5rem; border-radius: 4px;
            margin-top: 0.5rem; overflow-x: auto; font-family: monospace; font-size: 0.85rem;
            direction: ltr; text-align: left;
        }
        .loading { display: none; text-align: center; margin-top: 1.5rem; color: var(--text-muted); font-weight: 600; }
        .spinner {
            display: inline-block; width: 20px; height: 20px;
            border: 3px solid rgba(79, 70, 229, 0.3); border-radius: 50%;
            border-top-color: var(--primary-color); animation: spin 1s ease-in-out infinite;
            vertical-align: middle; margin-left: 8px;
        }

        /* استایل‌های اختصاصی رندر مارک‌داون و جداول */
        .output-content { line-height: 2; font-size: 15px; margin-top: 10px; }
        .output-content table { width: auto; min-width: 60%; margin: 20px auto; border-collapse: collapse; background-color: #ffffff; box-shadow: 0 3px 10px rgba(0,0,0,0.05); border-radius: 8px; overflow: hidden; }
        .output-content th, .output-content td { border: 1px solid #dcdde1; padding: 10px 15px; text-align: center; }
        .output-content th { background-color: #f1f2f6; border-bottom: 2px solid #a4b0be; }
        .output-content tr:nth-child(even) { background-color: #fbfbfb; }
        mjx-container { direction: ltr !important; display: inline-block; transition: none; }
        
        /* Modal Styles */
        .modal-overlay {
            display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0, 0, 0, 0.5); z-index: 1000;
            justify-content: center; align-items: center; padding: 1rem;
        }
        .modal-content {
            background: #fff; width: 100%; max-width: 800px; border-radius: 12px;
            padding: 1.5rem; box-shadow: 0 10px 25px rgba(0,0,0,0.2);
            animation: fadeIn 0.3s ease; display: flex; flex-direction: column; gap: 1rem;
        }
        .modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem;}
        .modal-header h3 { color: var(--primary-color); margin: 0;}
        .diff-container { display: flex; flex-direction: column; gap: 1rem; }
        @media(min-width: 600px) { .diff-container { flex-direction: row; } }
        .diff-box { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }
        .diff-box textarea { height: 200px; font-size: 0.85rem; }
        .modal-actions { display: flex; gap: 1rem; justify-content: flex-end; margin-top: 1rem; }
        .modal-actions button { width: auto; margin: 0;}

        @keyframes spin { to { transform: rotate(360deg); } }
        @keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }