:root {
            --primary: #2563eb;
            --success: #10b981;
            --warning: #f59e0b;
            --danger: #ef4444;
            --purple: #8b5cf6;
            --bg-color: #f8fafc;
            --sidebar-width: 350px;
        }

        body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg-color); margin: 0; padding: 20px; color: #334155; }
        
        /* TOAST & LAYOUT */
        #toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
        .toast { background: white; min-width: 300px; padding: 16px 20px; border-radius: 12px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); display: flex; align-items: center; gap: 12px; animation: slideIn 0.3s ease-out; border-left: 5px solid #ccc; }
        .toast.success { border-left-color: var(--success); } .toast.error { border-left-color: var(--danger); } .toast.info { border-left-color: var(--primary); }
        .container { max-width: 1400px; margin: 0 auto; display: flex; gap: 30px; }
        
        /* SIDEBAR */
        .sidebar { width: var(--sidebar-width); flex-shrink: 0; position: sticky; top: 20px; background: white; padding: 25px; border-radius: 16px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); border: 1px solid #e2e8f0; height: fit-content; }
        .main-content { flex-grow: 1; display: flex; flex-direction: column; gap: 20px; }
                /* Đổi màu chữ và in đậm cho thẻ a đang active */
        .tool-menu-link.active {
            color: #ff6600 !important; /* Thay mã màu bạn thích */
            font-weight: bold;
        }

        /* (Tùy chọn) Đổi màu nền cho cả thẻ li chứa nó để nổi bật hơn */
        .tool-menu-item.active-item {
            background-color: #f5f5f5; 
            border-left: 4px solid #ff6600; /* Thanh viền bên trái */
        }
        /* DANH MỤC LINK TOOL KHÁC (SIDEBAR) - ĐÃ CẬP NHẬT */
        .tool-menu-list { list-style: none; padding: 0; margin: 0; }
        .tool-menu-item { border-bottom: 1px dashed #cbd5e1; }
        .tool-menu-item:last-child { border-bottom: none; }
        .tool-menu-link { display: flex; align-items: center; gap: 10px; padding: 10px 5px; color: #475569; text-decoration: none; font-size: 0.95rem; font-weight: 500; transition: all 0.2s; }
        .tool-menu-link:hover { color: var(--primary); padding-left: 10px; background: #f8fafc; }
        .tool-menu-link i { color: #94a3b8; font-size: 0.8rem; transition: color 0.2s; }
        .tool-menu-link:hover i { color: var(--primary); }
        /* --- CUSTOM DROPDOWN STYLE --- */
                
        /* Tùy chỉnh TỪNG DÒNG (Cho phép xuống dòng hiển thị full text) */
        .custom-option-item { padding: 12px 15px; cursor: pointer; font-size: 13px; border-bottom: 1px dashed #e2e8f0; white-space: normal; /* Lệnh "ăn tiền" giúp chữ tự xuống dòng */ line-height: 1.5; color: #475569; transition: background 0.2s; }
        .custom-option-item:last-child { border-bottom: none; }
        .custom-option-item:hover { background-color: #f0fdf4; color: var(--success); font-weight: 500; border-left: 3px solid var(--success); padding-left: 12px; }

        @keyframes fadeInDown { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
       /* ÉP CHUẨN KÍCH THƯỚC CỘT 50/50 */
        .flex-row { display: flex; gap: 20px; margin: 15px 0; width: 100%; box-sizing: border-box; }
        .col { flex: 1; min-width: 0; width: 0; } /* Lệnh width: 0 cực kỳ quan trọng ở đây */
        /* --- CUSTOM DROPDOWN STYLE (BẢN FIX CUỐI CÙNG) --- */
        .custom-select-container { position: relative; width: 100%; }
        
        /* Đã xóa overflow: hidden để Tooltip được phép nổi ra ngoài */
        .custom-select-trigger { 
            padding: 12px 15px; 
            border: 1px solid #cbd5e1; 
            border-radius: 8px; 
            background: #fff; 
            cursor: pointer; 
            display: flex; 
            justify-content: space-between; 
            align-items: center; 
            font-size: 14px; 
            color: #334155; 
            transition: all 0.2s; 
            width: 100%; 
            box-sizing: border-box; 
            position: relative; 
        }
        .custom-select-trigger:hover { border-color: var(--primary); }
        .custom-select-trigger.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
        
        /* BẮT CHỮ PHẢI CẮT KHI CHẠM RÌA */
        .custom-select-trigger span { 
            white-space: nowrap; 
            overflow: hidden; 
            text-overflow: ellipsis; 
            flex: 1; 
            min-width: 0; 
            width: 0; /* Ép thẻ span không được tự giãn */
            margin-right: 10px; 
            display: block; 
        }        
        /* Quan trọng nhất: Không cho mũi tên bị ép méo hoặc văng ra ngoài */
        .custom-select-trigger i { flex-shrink: 0; }
        
        /* Bảng xổ xuống */
        .custom-options-list { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid #cbd5e1; border-top: none; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); z-index: 99; max-height: 280px; overflow-y: auto; display: none; }
        .custom-options-list.open { display: block; animation: fadeInDown 0.2s ease-out; }
        
        /* Tùy chỉnh TỪNG DÒNG */
        .custom-option-item { padding: 12px 15px; cursor: pointer; font-size: 13px; border-bottom: 1px dashed #e2e8f0; white-space: normal; line-height: 1.5; color: #475569; transition: background 0.2s; }
        .custom-option-item:last-child { border-bottom: none; }
        .custom-option-item:hover { background-color: #f0fdf4; color: var(--success); font-weight: 500; border-left: 3px solid var(--success); padding-left: 12px; }
        /* --- CSS TOOLTIP CUSTOM SIÊU ĐẸP --- */
        .custom-select-trigger {
            position: relative; /* Thêm dòng này để làm gốc tọa độ cho Tooltip */
        }

        /* Khung chứa chữ của Tooltip */
        .custom-select-trigger[data-tooltip]:hover::after {
            content: attr(data-tooltip);
            position: absolute;
            bottom: calc(100% + 8px); /* Nổi lên trên khung chọn 8px */
            left: 50%;
            transform: translateX(-50%);
            background-color: #334155; /* Màu nền tối sang trọng */
            color: #f8fafc;
            padding: 8px 12px;
            border-radius: 6px;
            font-size: 12px;
            line-height: 1.5;
            white-space: normal;
            max-width: 280px;
            width: max-content; /* Tự co giãn theo chữ, tối đa 280px */
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
            z-index: 1000;
            pointer-events: none;
            opacity: 0;
            visibility: hidden;
            transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
        }

        /* Mũi tên tam giác chỉ xuống của Tooltip */
        .custom-select-trigger[data-tooltip]:hover::before {
            content: '';
            position: absolute;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%);
            border-width: 6px;
            border-style: solid;
            border-color: #334155 transparent transparent transparent;
            z-index: 1000;
            pointer-events: none;
            opacity: 0;
            visibility: hidden;
            transition: opacity 0.2s ease, visibility 0.2s ease;
        }

        /* Hiệu ứng mờ dần khi Hover */
        .custom-select-trigger[data-tooltip]:not(.active):hover::after,
        .custom-select-trigger[data-tooltip]:not(.active):hover::before {
            opacity: 1;
            visibility: visible;
        }

        /* Ẩn Tooltip khi click mở Dropdown để không bị vướng mắt */
        .custom-select-trigger.active::after,
        .custom-select-trigger.active::before {
            display: none !important;
        }
        /* ELEMENTS */
        h2 { margin-top: 0; font-size: 1.1rem; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; border-bottom: 2px solid #f1f5f9; padding-bottom: 12px; margin-bottom: 20px; }
        h3 { margin: 0; font-size: 1.1rem; font-weight: 700; }
        label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 0.85rem; color: #64748b; text-transform: uppercase; }
        textarea, input, select { width: 100%; padding: 12px 15px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; background: #fff; box-sizing: border-box; }
        textarea:focus, input:focus, select:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
        .dna-box { min-height: 120px; font-family: 'Consolas', monospace; }

        /* SCENE CARDS */
        .scene-card { background: white; padding: 25px; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); border-left: 5px solid #ccc; position: relative; }
        .scene-hook { border-color: var(--success); } .scene-hook h3 { color: var(--success); }
        .scene-body { border-color: var(--warning); } .scene-body h3 { color: var(--warning); }
        .scene-cta { border-color: var(--danger); } .scene-cta h3 { color: var(--danger); }

        
        /* Cập nhật lại thẻ select để cắt chữ dài thành dấu ... */
        textarea, input, select { 
            width: 100%; 
            padding: 12px 15px; 
            border: 1px solid #cbd5e1; 
            border-radius: 8px; 
            font-size: 14px; 
            background: #fff; 
            box-sizing: border-box; 
        }
        
        select {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        /* WORD COUNTER BADGE */
        .counter-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; background: #f1f5f9; color: #64748b; margin-top: 5px; margin-bottom: 10px; transition: all 0.3s; }
        .counter-badge.warning { background: #fef2f2; color: var(--danger); }
        .counter-badge.safe { background: #ecfdf5; color: var(--success); }

        /* AUDIO SECTION */
        .audio-section { background: #f5f3ff; padding: 15px; border-radius: 8px; margin-top: 5px; border: 1px dashed var(--purple); }
        .audio-label { color: var(--purple); display: flex; align-items: center; gap: 8px; }
        
        /* BUTTONS */
        .btn { border: none; padding: 12px 20px; border-radius: 8px; cursor: pointer; font-weight: 600; transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; }
        .btn:hover { transform: translateY(-1px); }
        .btn-add { background: #fffbeb; color: #d97706; border: 1px dashed #fcd34d; width: 100%; }
        .btn-del { position: absolute; top: 20px; right: 20px; background: transparent; color: #94a3b8; padding: 5px; }
        .btn-del:hover { color: var(--danger); background: #fef2f2; }
        .btn-generate { background: var(--primary); color: white; font-size: 1.1rem; padding: 16px; width: 100%; margin-top: 10px; }

        /* RESULTS AREA */
        .results-area { margin-top: 40px; display: none; animation: slideUp 0.5s ease; }
        @keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
        .output-card { background: white; border-radius: 12px; overflow: hidden; margin-bottom: 20px; border: 1px solid #e2e8f0; }
        .output-header { background: #f8fafc; padding: 12px 20px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: #475569; }
        .output-body { padding: 20px; font-family: 'Consolas', monospace; font-size: 0.9rem; line-height: 1.6; color: #334155; }
        .btn-copy-sm { background: white; border: 1px solid #cbd5e1; padding: 6px 12px; font-size: 0.8rem; border-radius: 6px; cursor: pointer; }

        /* Responsive */
        @media (max-width: 1000px) { .container { flex-direction: column; } .sidebar { width: auto; position: static; } }