
    /* فونت وزیرمتن برای نمایش زیبای فارسی */
   
    :root {
        --primary: #2e7d32;
        --primary-dark: #1b5e20;
        --secondary: #4caf50;
        --accent: #ff9800;
        --bg-light: #f4f6f8;
        --surface: #ffffff;
        --text-main: #263238;
        --text-light: #546e7a;
        --border: #cfd8dc;
        --shadow: 0 4px 6px rgba(0,0,0,0.05);
        --radius: 12px;
        --header-height: 60px;
    }
    
    * { box-sizing: border-box; outline: none; }
    
    body {
        font-family: 'Vazirmatn', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        background-color: var(--bg-light);
        color: var(--text-main);
        margin: 0;
        display: flex;
        flex-direction: column;
        height: 100vh;
        overflow: hidden; /* جلوگیری از اسکرول کل بادی */
        transition: direction 0.3s;
    }
    /* --- Header --- */
    header {
        background: linear-gradient(135deg, var(--primary-dark), var(--primary));
        color: white;
        padding: 0 15px;
        height: var(--header-height);
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        z-index: 20;
        flex-shrink: 0;
    }
    
    .brand { 
        font-size: 1.1rem; 
        font-weight: bold; 
        display: flex; 
        align-items: center; 
        gap: 8px; 
        white-space: nowrap;
    }
    
    .actions { display: flex; gap: 8px; }
    
    .actions button {
        background: rgba(255,255,255,0.2);
        border: none;
        color: white;
        padding: 8px 12px;
        border-radius: 6px;
        cursor: pointer;
        font-size: 0.85rem;
        transition: 0.3s;
        white-space: nowrap;
    }
    
    html[dir="ltr"] .actions button { margin-left: 0; margin-right: 5px; }
    .actions button:hover { background: rgba(255,255,255,0.3); }
    /* --- Layout --- */
    .app-container {
        display: flex;
        flex: 1;
        overflow: hidden;
        position: relative;
    }
    /* --- Sidebar (Profile) --- */
    aside {
        width: 300px;
        background: var(--surface);
        border-left: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        padding: 20px;
        overflow-y: auto;
        z-index: 15;
        transition: transform 0.3s ease, width 0.3s ease;
        flex-shrink: 0;
    }
    
    html[dir="ltr"] aside { border-left: none; border-right: 1px solid var(--border); }
    
    aside h3 { 
        font-size: 1rem; 
        color: var(--primary); 
        margin-bottom: 15px; 
        border-bottom: 2px solid var(--bg-light); 
        padding-bottom: 5px; 
    }
    
    .profile-group { margin-bottom: 20px; }
    .profile-group label { display: block; font-size: 0.85rem; color: var(--text-light); margin-bottom: 5px; }
    .profile-group input, .profile-group select {
        width: 100%;
        padding: 10px;
        border: 1px solid var(--border);
        border-radius: 6px;
        font-size: 0.9rem;
    }
    
    .phase-viz {
        margin-top: auto;
        background: var(--bg-light);
        padding: 10px;
        border-radius: 8px;
    }
    .bar-container { display: flex; height: 20px; border-radius: 4px; overflow: hidden; margin-top: 5px; }
    .bar-s { background: #795548; width: 50%; transition: width 0.5s; }
    .bar-w { background: #2196f3; width: 25%; transition: width 0.5s; }
    .bar-a { background: #e0e0e0; width: 25%; transition: width 0.5s; }
    .legend { display: flex; justify-content: space-between; font-size: 0.7rem; margin-top: 5px; color: var(--text-light); }
    /* --- Main Content --- */
    main {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        position: relative;
        min-width: 0; /* جلوگیری از بیرون زدن گرید */
    }
    /* Navigation Tabs */
    .nav-tabs {
        display: flex;
        background: var(--surface);
        padding: 0 10px;
        border-bottom: 1px solid var(--border);
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch; /* اسکرول نرم در iOS */
        scrollbar-width: none; /* فایرفاکس */
        flex-shrink: 0;
    }
    .nav-tabs::-webkit-scrollbar { display: none; /* کروم و سافاری */ }
    .nav-item {
        padding: 15px 18px;
        cursor: pointer;
        color: var(--text-light);
        font-weight: 500;
        border-bottom: 3px solid transparent;
        transition: 0.3s;
        flex-shrink: 0;
        font-size: 0.9rem;
    }
    .nav-item:hover { color: var(--primary); background: #fafafa; }
    .nav-item.active { color: var(--primary); border-bottom-color: var(--primary); }
    /* Content Area */
    .content-scroll {
        flex: 1;
        padding: 20px;
        overflow-y: auto;
        scroll-behavior: smooth;
    }
    .tool-section { display: none; animation: fadeIn 0.4s ease; }
    .tool-section.active { display: block; }
    @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
    .card {
        background: var(--surface);
        border-radius: var(--radius);
        padding: 20px;
        box-shadow: var(--shadow);
        margin-bottom: 20px;
        border: 1px solid var(--border);
    }
    .card h2 { 
        font-size: 1.2rem; 
        color: var(--text-main); 
        margin-bottom: 15px; 
        display: flex; 
        align-items: center; 
        gap: 10px; 
    }
    .card h2::before { content: ''; display: block; width: 5px; height: 20px; background: var(--accent); border-radius: 2px; }
    /* Responsive Grids */
    .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
    .grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
    .input-box { margin-bottom: 15px; }
    .input-box label { display: block; margin-bottom: 6px; font-size: 0.9rem; font-weight: 500; }
    .input-box input {
        width: 100%;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 8px;
        font-size: 1rem;
        transition: 0.3s;
    }
    .input-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1); }
    .input-box input[readonly] { background: #f5f5f5; color: #333; font-weight: bold; cursor: default; }
    .btn-calc {
        background: var(--primary);
        color: white;
        border: none;
        padding: 12px 25px;
        border-radius: 8px;
        font-size: 1rem;
        cursor: pointer;
        width: 100%;
        font-weight: bold;
        transition: 0.3s;
    }
    .btn-calc:hover { background: var(--primary-dark); transform: translateY(-1px); }
    .result-box {
        background: #e8f5e9;
        border: 1px solid #c8e6c9;
        padding: 15px;
        border-radius: 8px;
        margin-top: 20px;
        display: none;
    }
    .result-box.show { display: block; }
    .result-row { display: flex; justify-content: space-between; margin-bottom: 8px; border-bottom: 1px dashed #a5d6a7; padding-bottom: 5px; font-size: 0.9rem; }
    .result-row:last-child { border: none; margin: 0; }
    .res-val { font-weight: bold; color: var(--primary-dark); }
    
    /* --- Styles for Calculation Steps --- */
    .calc-steps {
        margin-top: 15px;
        padding: 12px;
        background: #fff3e0; /* رنگ پس‌زمینه متفاوت برای مراحل */
        border: 1px solid #ffe0b2;
        border-radius: 6px;
        font-size: 0.85rem;
        color: #5d4037;
    }
    .calc-steps h4 {
        margin: 0 0 8px 0;
        font-size: 0.9rem;
        color: #e65100;
        border-bottom: 1px solid #ffe0b2;
        padding-bottom: 4px;
    }
    .step-line {
        margin-bottom: 6px;
        font-family: 'Courier New', Courier, monospace; /* فونت مونواسپیس برای فرمول‌ها */
        direction: ltr; /* فرمول‌ها چپ به راست خوانده می‌شوند */
        text-align: left;
        unicode-bidi: embed;
    }
    .step-desc {
        display: block;
        margin-bottom: 4px;
        font-family: inherit;
        direction: rtl; /* توضیحات فارسی راست به چپ */
        text-align: right;
        font-weight: bold;
    }

    /* Texture Viz */
    .texture-viz {
        width: 100%;
        height: 150px;
        background: #eee;
        margin-top: 15px;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        overflow: hidden;
    }
    .texture-bar-s { height: 100%; background: #fdd835; transition: width 0.5s; }
    .texture-bar-c { height: 100%; background: #795548; transition: width 0.5s; }
    .texture-bar-si { height: 100%; background: #a1887f; transition: width 0.5s; }
    .texture-label {
        position: absolute;
        color: #333;
        font-weight: bold;
        text-shadow: 0 0 2px white;
        font-size: 0.9rem;
    }
    /* --- Converter Modal --- */
    .modal-overlay {
        position: fixed; top: 0; right: 0; bottom: 0; left: 0;
        background: rgba(0,0,0,0.5);
        z-index: 100;
        display: none;
        justify-content: center;
        align-items: center;
        padding: 20px;
    }
    .modal {
        background: white;
        width: 100%;
        max-width: 500px;
        border-radius: var(--radius);
        padding: 25px;
        box-shadow: 0 10px 25px rgba(0,0,0,0.2);
        max-height: 90vh;
        overflow-y: auto;
    }
    .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
    .close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #666; }
    /* --- Mobile Sidebar Toggle Button --- */
    .mobile-sidebar-toggle {
        display: none;
        background: var(--surface);
        border: 1px solid var(--border);
        color: var(--primary);
        padding: 8px 12px;
        border-radius: 6px;
        font-size: 0.85rem;
        cursor: pointer;
        margin-bottom: 15px;
        align-items: center;
        justify-content: center;
        gap: 5px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }
    /* --- Print Styles --- */
    @media print {
        aside, .nav-tabs, .actions, header, .mobile-sidebar-toggle { display: none !important; }
        body, .app-container, main, .content-scroll { height: auto; overflow: visible; display: block; }
        .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
        .tool-section { display: block !important; margin-bottom: 40px; }
        .btn-calc { display: none; }
        .calc-steps { background: #fff; border: 1px dashed #ccc; color: #000; }
    }
    /* --- Responsive Design (Mobile & Tablet) --- */
    @media (max-width: 900px) {
        .app-container { flex-direction: column; }
        
        /* Sidebar Logic for Mobile */
        aside {
            width: 100%;
            height: auto;
            max-height: 0; /* مخفی کردن پیش‌فرض */
            padding: 0 20px;
            border-left: none;
            border-bottom: 1px solid var(--border);
            overflow: hidden;
            opacity: 0;
        }
        
        html[dir="ltr"] aside { border-right: none; }
        /* کلاس برای نمایش سایدبار در موبایل */
        aside.mobile-open {
            max-height: 500px; /* ارتفاع تقریبی برای باز شدن */
            padding: 20px;
            opacity: 1;
            overflow-y: auto;
            margin-bottom: 10px;
        }
        /* نمایش دکمه بازکننده سایدبار */
        .mobile-sidebar-toggle {
            display: flex;
        }
        /* Grid Adjustments */
        .grid-2 { grid-template-columns: 1fr; }
        .grid-3 { grid-template-columns: 1fr; }
        
        /* Content Padding */
        .content-scroll { padding: 15px; }
        
        /* Header Adjustments */
        .brand span { display: none; } /* مخفی کردن متن لوگو در صفحات خیلی کوچک اگر نیاز بود */
        .brand svg { display: block; }
        .brand span.mobile-visible { display: inline; }
    }
    @media (max-width: 480px) {
        header { padding: 0 10px; }
        .nav-item { padding: 12px 15px; font-size: 0.85rem; }
        .card { padding: 15px; }
        .btn-calc { padding: 10px; }
    }

