:root {
    --bg: #0f0f13;
    --card: #1a1a22;
    --primary: #6c5ce7;
    --primary-glow: rgba(108, 92, 231, 0.4);
    --text: #eaeaea;
    --text-muted: #8b8b9e;
    --border: #2a2a35;
    --success: #00b894;
    --danger: #ff7675;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Tajawal', sans-serif; 
    -webkit-tap-highlight-color: transparent; 
}

body { 
    background: var(--bg); 
    color: var(--text); 
    min-height: 100vh; 
    display: flex; 
    justify-content: center; 
    padding: 16px; 
}

.app-container { 
    width: 100%; 
    max-width: 500px; 
}

/* الترويسة */
header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 24px; 
}

.logo { 
    font-size: 1.4rem; 
    font-weight: 700; 
    color: #fff; 
}

.logo span { 
    color: var(--primary); 
}

.limit-badge { 
    background: rgba(108, 92, 231, 0.15); 
    color: var(--primary); 
    padding: 6px 12px; 
    border-radius: 20px; 
    font-size: 0.85rem; 
    font-weight: bold; 
    border: 1px solid var(--primary); 
    cursor: pointer; 
}

/* التبويبات */
.tabs { 
    display: flex; 
    background: var(--card); 
    border-radius: 12px; 
    padding: 4px; 
    margin-bottom: 20px; 
    border: 1px solid var(--border); 
}

.tab { 
    flex: 1; 
    padding: 10px; 
    border: none; 
    background: none; 
    color: var(--text-muted); 
    font-size: 0.9rem; 
    font-weight: bold; 
    border-radius: 8px; 
    cursor: pointer; 
    transition: 0.3s; 
}

.tab.active { 
    background: var(--primary); 
    color: #fff; 
}

/* البطاقات والمدخلات */
.card { 
    background: var(--card); 
    border-radius: 16px; 
    padding: 20px; 
    border: 1px solid var(--border); 
    margin-bottom: 20px; 
}

label { 
    display: block; 
    margin-bottom: 8px; 
    color: var(--text-muted); 
    font-size: 0.9rem; 
}

textarea, select { 
    width: 100%; 
    padding: 14px; 
    background: var(--bg); 
    border: 1px solid var(--border); 
    border-radius: 10px; 
    color: #fff; 
    margin-bottom: 16px; 
    font-size: 1rem; 
    outline: none; 
    transition: 0.3s; 
}

textarea { 
    min-height: 100px; 
    resize: vertical; 
}

textarea:focus, select:focus { 
    border-color: var(--primary); 
    box-shadow: 0 0 0 2px var(--primary-glow); 
}

/* الوسوم (Tags) */
.tags { 
    display: flex; 
    gap: 8px; 
    flex-wrap: wrap; 
    margin-bottom: 16px; 
}

.tags button { 
    background: rgba(108, 92, 231, 0.1); 
    border: 1px solid var(--primary); 
    color: #a29bfe; 
    padding: 6px 12px; 
    border-radius: 20px; 
    font-size: 0.85rem; 
    cursor: pointer; 
    transition: 0.2s;
}

.tags button:active { 
    background: var(--primary); 
    color: #fff; 
}

/* الأزرار الرئيسية */
.main-btn { 
    width: 100%; 
    padding: 16px; 
    border: none; 
    border-radius: 10px; 
    background: var(--primary); 
    color: #fff; 
    font-size: 1.1rem; 
    font-weight: bold; 
    cursor: pointer; 
    transition: 0.3s; 
    box-shadow: 0 4px 15px var(--primary-glow); 
}

.main-btn:disabled { 
    background: #4a3f99; 
    box-shadow: none; 
    cursor: not-allowed; 
}

/* حالة التحميل */
.status { 
    text-align: center; 
    color: #fdcb6e; 
    margin: 16px 0; 
    font-size: 0.95rem; 
    font-weight: bold; 
}

.hidden { 
    display: none !important; 
}

/* صندوق النتيجة */
.result-box { 
    background: var(--card); 
    border-radius: 16px; 
    padding: 16px; 
    border: 1px solid var(--border); 
    margin-bottom: 20px; 
}

.image-wrapper { 
    position: relative; 
    min-height: 200px; 
    background: var(--bg); 
    border-radius: 12px; 
    overflow: hidden; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    margin-bottom: 12px; 
}

.image-wrapper img { 
    width: 100%; 
    border-radius: 12px; 
    display: none; 
}

.loader { 
    display: none; 
    width: 40px; 
    height: 40px; 
    border: 4px solid var(--border); 
    border-top: 4px solid var(--primary); 
    border-radius: 50%; 
    animation: spin 1s linear infinite; 
}

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

/* أزرار الإجراءات (تحميل، حفظ، مشاركة) */
.action-buttons { 
    display: flex; 
    gap: 8px; 
    margin-top: 12px;
}

.action-buttons button { 
    flex: 1; 
    padding: 12px 4px; 
    border: none; 
    border-radius: 8px; 
    color: #fff; 
    font-size: 0.85rem; 
    font-weight: bold; 
    cursor: pointer; 
    transition: 0.2s;
}

.action-buttons button:active { 
    transform: scale(0.95); 
}

.download-btn { background: var(--success); }
.save-btn { background: #0984e3; }
.share-btn { background: #e17055; }

/* المكتبة */
.library-grid { 
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 12px; 
}

.library-item { 
    position: relative; 
    border-radius: 12px; 
    overflow: hidden; 
    border: 1px solid var(--border); 
    aspect-ratio: 1; 
    background: var(--bg);
}

.library-item img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
}

.delete-btn { 
    position: absolute; 
    top: 8px; 
    right: 8px; 
    background: rgba(255, 118, 117, 0.9); 
    border: none; 
    border-radius: 50%; 
    width: 32px; 
    height: 32px; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    color: white; 
    font-size: 14px; 
    cursor: pointer; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.5); 
    transition: 0.2s;
}

.delete-btn:active {
    transform: scale(0.9);
}

/* نصوص إضافية */
.coming-soon { 
    text-align: center; 
    padding: 20px 0; 
    color: var(--text-muted); 
}